#ifndef __MEMORY_ROUTINES__
#define __MEMORY_ROUTINES__

static __device__ void scatterRowVector(unsigned int tid, float* data, int dimension, float* dest) {
	for(int i=tid; i<dimension; i += blockDim.x, data+=blockDim.x) {
		dest[i] = *data;
	}
}

static __device__ void scatterTextureRowVector(int tid, float* dest, int idxX, int dimension) {
	for(int i=tid; i<dimension; i += blockDim.x) {
		dest[i] = 0.0f;
	}
	__shared__ int len;
	if(tid == 0) {
		len = tex1Dfetch(ellRowLenTex, idxX);
	}
	__syncthreads();
	for(int i=tid; i<len;i+=blockDim.x) {
		int2 X = tex2D(ellDataTex, idxX, i);
		dest[X.x] = __int_as_float(X.y);
	}
}

#endif
